package org.gorson.function;


import org.apache.flink.streaming.api.functions.ProcessFunction;
import org.apache.flink.util.Collector;
import org.gorson.BO.AssetDetailBO;
import org.gorson.utils.CastUtil;

public class ProcessAlipayToAssetDetailFunction extends ProcessFunction<String, AssetDetailBO> {
    @Override
    public void processElement(String sentence, Context context, Collector<AssetDetailBO> collector) throws Exception {
        collector.collect(this.map(sentence));
    }

    private AssetDetailBO map(String sentence) {
        String[] strArr = sentence.split(",");
        AssetDetailBO assetDetail = new AssetDetailBO();
        assetDetail.setTransFirm("Alipay");
        assetDetail.setPayCode(CastUtil.castString(strArr[0].replaceAll(" ", ""), null));
        assetDetail.setTransAmt(CastUtil.castString(strArr[5].replaceAll(" ", ""), null));
        assetDetail.setTransSummary(CastUtil.castString((strArr[1] + "-" +strArr[3]).replaceAll(" ", ""),null));
        assetDetail.setTransDate(CastUtil.castString(strArr[10].substring(0,strArr[10].indexOf(" ")), null));
        assetDetail.setTransStatus(CastUtil.castString(strArr[6].replaceAll(" ", ""), null));
//        repayPlan.setAssetSide(CastUtil.castString(strArr[0].replaceAll("\"", ""), null));
        return assetDetail;
    }
}
